package kr.hkit.powerjava.chapter11;
class Fly{
	String name;

	@Override
	public String toString() {
		return name;
	}
	
	
}


public class SportCar extends Car {
	boolean turbo;

	public void setTurbo(boolean turbo) {
		this.turbo = turbo;
	}
	@Override
	public String toString() {
		return String.format("object[%s] - > Car [%s, %s, %s]", 
				super.toString(), speed, gear, color); //object클래스에 있는 toString()이다.
	}
	public static void main(String[] args) {
		Car car = new Car();
		car.gear = 1;
		car.color = "red";
		car.speedUp(60);
		

		
		Car car2 = new Car();
		car2.gear = 2;
		car2.color = "blue";
		car2.speedUp(80);
		
		
		Fly fly = new Fly();
		fly.name = "fly01";
		
		Fly fly2 = new Fly();
		fly2.name = "fly01";
		
		Car[] arrCar = new Car[2];
		Fly[] arrFly = new Fly[2];
		
		arrCar[0] = car;
		arrCar[1] = car2;
		
		arrFly[0] = fly;
		arrFly[1] = fly2;
		
		prnArr(arrCar);
		prnArr(arrFly);
		
		Object[] arrObj = new Object[4];
		arrObj[0]=car;
		arrObj[1]=car2;
		arrObj[2]=fly;
		arrObj[3]=fly2;
		
		prnArr(arrObj);
		
		System.out.println(car.getClass().getName());
		
/*		System.out.println(car);
		
		Object obj = car; //부모클래스라서 오류가 안난다.
		System.out.println(obj.toString());
		*/
		/*Car car2 = new Object();  자식은 부모를 못 받는다..*/
		
	}
	@Override
	public void speedUp(int increment) {
		// TODO Auto-generated method stub
		super.speedUp(increment);
	}
	private static void prnArr(Object[] arrObj) {
		for (int i = 0; i < arrObj.length; i++) {
			System.out.println(arrObj[i]);
		}
		System.out.println();
	}
	private static void prnArr(Car[] arrCar) {
		for (int i = 0; i < arrCar.length; i++) {
			System.out.println(arrCar[i]);
		}
		System.out.println();
	}
	private static void prnArr(Fly[] arrFly) {
		for (int i = 0; i < arrFly.length; i++) {
			System.out.println(arrFly[i]);
		}
	}
	
	
}
